#ifndef DATABASE_H
#define DATABASE_H

#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
#include <QSqlRecord>
#include "MedicalInfo.h"

class Database
{
public:
    static Database* getInstance();

    /* 患者信息 */
    int addPatient(PatientInfo* info);
    int deletePatient(int number);
    int modifyPatient(PatientInfo* info);
    int getFreePatientNumber();
    int getMaxPatientNumber();
    PatientInfo* queryPatient(int number);
    QList<PatientInfo*>* queryPatient();
    QList<PatientInfo*>* queryPatient(const QString &type);
private:
    Database();
    QSqlDatabase g_database;
    QSqlQuery*  g_sqlQuery;
    int g_initState = -1;

    void createPatientTable();
    void freePatientInfo(QList<PatientInfo*>* list);
};

#endif // DATABASE_H
